package _interview100;

import java.util.HashMap;

/**
 * 1. 两数之和
 */
public class No1 {
    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> hashMap = new HashMap<>();

        for (int i = 0; i < nums.length; i++) {
            if (hashMap.containsKey(target - nums[i])) {
                return new int[]{i, hashMap.get(target - nums[i])};
            }

            hashMap.put(nums[i], i);
        }

        return null;
    }
}

